package com.jame.concurrency.cas;

import org.openjdk.jol.info.ClassLayout;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author : Jame
 * @date : 2021-07-11 19:17
 **/
public class LockUpDemo {
    public static void main(String[] args) throws InterruptedException {
        A a1 = new A();
        System.out.println(ClassLayout.parseInstance(a1).toPrintable());

        Thread.sleep(5000);

        A a = new A();
        System.out.println(ClassLayout.parseInstance(a).toPrintable());

        synchronized (a) {
            System.out.println(ClassLayout.parseInstance(a).toPrintable());
        }
        synchronized (a) {
            System.out.println(ClassLayout.parseInstance(a).toPrintable());
        }


        new Thread(() -> {
            synchronized (a) {
                System.out.println(ClassLayout.parseInstance(a).toPrintable());
            }
        }).start();


        ReentrantLock reentrantLock = new ReentrantLock();

        reentrantLock.lock();





//
//
//        Thread.sleep(500);
//
//
//        new Thread(() -> {
//            synchronized (a) {
//
//                System.out.println(ClassLayout.parseInstance(a).toPrintable());
//            }
//        }).start();

    }
}
